<!--
 * @Author: your name
 * @Date: 2020-12-21 10:40:28
 * @LastEditTime: 2021-04-01 11:12:00
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\warranty\warranty.vue
-->
<template>
    <div class="warranty-mian-box-spa">
        <BaseHeader returnMain='/installationGuide' :sn='$route.query.sn'></BaseHeader>
        <div class="content-box" v-loading='loading'>
            <div class="header-box"><h1>WARRANTY</h1></div>
            <div class="message-box-main">
                <h3>{{$t('warranty.pages.massage.h3')}}</h3>
                <h6>{{$t('warranty.pages.massage.h6')}}</h6>
            </div>
            <!-- -->
            <div class="form-item-bos">
                <el-form ref="form" :model="form" label-width="120px" label-position="top" >
                    <el-row :gutter="20" style="margin:0px;">
                        <el-col :span="14" :offset="4">
                            <el-form-item :label="$t('installationGuide.expireTime')" v-if='expireTime'>
                                <p style="color:red;">{{expireTime}}</p>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.yourName')" prop="userName" :rules="[{ required: false, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.userName" :placeholder="$t('pleaseInput')"></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.address')" prop="address" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.address" :placeholder="$t('pleaseInput')"></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.postCode')" prop="postCode" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.postCode" :placeholder="$t('pleaseInput')"></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.photoNumber')" prop="phone" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.phone" :placeholder="$t('pleaseInput')"></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.addData')" prop="installTime" :rules="[{ required: true, message: $t('index_js_notNull')}]"
                            
                            >
                                <el-date-picker
                                v-model="form.installTime"
                                type="date"
                                :placeholder="$t('selectDate')"
                                value-format='yyyy-MM-dd'
                                :clearable='true'
                                :picker-options="pickerOptions"
                                :disabled='expireTime?(disabledFlag || disabledFlag2):false'
                                >
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.addName')" prop="installer" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.installer" :placeholder="$t('pleaseInput')"></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('warrantyStatistics.nation')" prop="nation" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                                <el-select v-model="form.nation" filterable :placeholder="$t('pleaseSelect')" clearable :disabled='expireTime?(disabledFlag || disabledFlag2):false' @change='nationChange'>
                                    <el-option
                                        v-for="item in nationList"
                                        :key="item.enName"
                                        :label="item.enName"
                                        :value="item.enName"
                                        style="display:block;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;max-width:250px;overflow:visible;height:auto;line-height:normal;padding:10px 10px;"
                                        >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="Social Energy Installation" prop="IsSEACKIT" :rules="[{ required: true, message: $t('index_js_notNull')}]" v-if='form.nation == "UNITED KINGDOM"'>
                                <el-radio v-model="form.IsSEACKIT" :label="0">Yes</el-radio>
                                <el-radio v-model="form.IsSEACKIT" :label="1">No</el-radio>
                            </el-form-item>
                            <el-form-item :label="$t('warrantyManage.serial_number')" prop="inverterSn" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.inverterSn" :placeholder="$t('pleaseInput')" @blur="getInverterType" :disabled='expireTime?(disabledFlag || disabledFlag2):false'></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('invoice.deviceType')" prop="model" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                                <el-select v-model="form.model" filterable :placeholder="$t('pleaseInput')" clearable style="width:100%" :disabled='expireTime?(disabledFlag || disabledFlag2):false'>
                                    <el-option
                                        v-for="item in inverterType"
                                        :key="item.sid"
                                        :label="item.inverterTypeName"
                                        :value="item.inverterTypeName">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item v-if='returnOtherName(form.model) == 99' :label="$t('warranty.other')" prop="model" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.deviceTypeName" :placeholder="$t('pleaseInput')" :disabled='expireTime?(disabledFlag || disabledFlag2):false'></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('email')" prop="email" :rules="[{ required: true, message: $t('index_js_notNull')},{ type: 'email', message:$t('user.msg_reg_email'), trigger: ['blur', 'change']}]">
                                <el-input v-model="form.email" :placeholder="$t('pleaseInput')" ></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.emailCC.msg')" prop="ccEmail" :rules="[{ required: false, message: $t('index_js_notNull')},{ type: 'email', message:$t('user.msg_reg_email'), trigger: ['blur', 'change']}]">
                                <el-input v-model="form.ccEmail" :placeholder="$t('pleaseInput')" style="width:90%;"></el-input>
                            <el-tooltip class="icon-nmi" placement="top">
                                <div slot="content">
                                    {{$t('warranty.emailCC.will')}}
                                </div>
                                <i class="el-icon-question iconClass"></i>
                            </el-tooltip>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.SsrotNumber')" prop="delayCode" :rules="[{ required: false, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.delayCode" :placeholder="$t('pleaseInput')" ></el-input>
                            </el-form-item>
                            <el-form-item :label="$t('warranty.ZsrotNumber')" prop="saleCode" :rules="[{ required: false, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.saleCode" :placeholder="$t('pleaseInput')" ></el-input>
                            </el-form-item>
                            <el-form-item v-if='!expireTime' :label=" $t('warranty.BsrotNumber') + '(' +  $t('warranty.newAddDataMsgWarrany') + ')' " prop="batterySN" :rules="[{ required: false, message: $t('index_js_notNull')}]">
                                <el-input v-model="form.batterySN" :placeholder="$t('pleaseInput')" ></el-input>
                            </el-form-item>
                            <template v-for='(value,key,index) in form.batteryListForm' v-if='expireTime'>
                                <el-form-item :label="$t('warranty.BsrotNumber')" :prop="'batteryListForm.item'+(index+1)+'.sn'" :rules="[{ required: false, message: $t('index_js_notNull')}]" :key='key' style="position: relative;">
                                    <el-input v-model="form.batteryListForm[key]['sn']" :placeholder="$t('pleaseInput')" @blur="blurBatterySn(form.batteryListForm[key]['sn'])" :disabled='disabledFlag && returnExamineBattery(form.batteryListForm[key]["sn"],form.batteryListForm[key]["id"])'></el-input>

                                    <span v-if='index == Object.keys(form.batteryListForm).length-1' style="display: block;line-height: 35px;color:green;  font-size: 18px;position: absolute;top: -36px;right: 30px;" @click='pushBatterySn'><i class="el-icon-circle-plus"></i></span>
                                    
                                    <span v-if="!returnExamineBattery(form.batteryListForm[key]['sn'],form.batteryListForm[key]['id'])" style="display: block;line-height: 35px;color:red;  font-size: 18px;position: absolute;top: -36px;right: 0px;" @click='deleteBatterySn(value)'><i class="el-icon-error"></i></span>
                                    
                                </el-form-item>
                                <el-form-item :label="$t('warranty.batteryMsg.tiem')" :prop="'batteryListForm.item'+(index+1)+'.date'" :rules="[{ required: value.sn?true:false, message: $t('index_js_notNull')}]" :key='key+1'>
                                    <el-date-picker
                                    v-model="form.batteryListForm[key]['date']"
                                    type="date"
                                    :placeholder="$t('selectDate')"
                                    value-format='yyyy-MM-dd'
                                    :clearable='true'
                                    :picker-options="pickerOptions"
                                    :disabled='disabledFlag && returnExamineBattery(form.batteryListForm[key]["sn"],form.batteryListForm[key]["id"])'
                                    >
                                    </el-date-picker>
                                </el-form-item>
                            </template>

                            <el-form-item  >
                                <div class="save-button-style" @click='save'>{{$t('user.updateUserName.send')}}</div>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div> 
        </div>
    </div>
</template>

<script>
import BaseHeader from '../../components/baseHeader'
export default {
    components: {
        BaseHeader
    },
    props: {

    },
    data() {
        return {
            loading:false,
            form:{
                loginName:'',
                userName:'',
                address:'',
                postCode:'',
                phone:'',
                installTime:'',
                installer:'',
                nation:'',
                IsSEACKIT:'',
                inverterSn:'',
                model:'',
                email:'',
                delayCode:'',
                saleCode:'',
                batterySN:'',
                ccEmail:'',
                batteryList:[],
                batteryListForm:{item1:{sn:'',date:'',flag:'1'}},
                deviceTypeName:''
            },
            getBuyIdRes:{},
            expireTime:'',
            nationList:[],
            inverterType:[],
            pickerOptions:{ //禁用今天之后的时间
                disabledDate(time) {
                    return time.getTime() > Date.now()
                }
            },
            oldSN:'',
            flagType:false,
            disabledFlag:true,
            disabledFlag2:true,
            copyInverter:[],
            unlockBattery:'',
        };
    },
    computed: {
        deviceType(){
            let type= ''
            this.inverterType.forEach(item =>{
                if(item.inverterTypeName == this.form.model){
                    type = item.inverterType
                }
            })
            return type
        }
    },
    watch: {

    },
    created() {

    },
    mounted() {
        this.selectCountry()
        this.orderpaypalconfigGetInverterTypeList()
        if(this.$route.query.sn){
            this.qualityGetById(this.$route.query.sn)
            this.form.inverterSn = this.$route.query.sn
        }

    },
    methods: {
        async deleteBatterySn(value){
            if(value.id){
                let res = await this.API.crmbatteryqualityDelete({
                    id:value.id
                })
                if(this.comm.showMsg(res.success)){
                    this.qualityGetById(this.$route.query.sn)
                }
            }else{
                let obj = {}
                for(let key in this.form.batteryListForm){
                    if(this.form.batteryListForm[key].index != value.index){
                        obj[key] = this.form.batteryListForm[key]
                    }
                }
                this.form.batteryListForm = obj
            }
            
        },
        getRandomNumber (min, max) {
            return Math.floor(Math.random() * (max - min + 1) + min)
        },
        returnOtherName(code){
            let type = ''
            this.inverterType.forEach(item=>{
                if(item.inverterTypeName == code){
                    type = item.inverterType
                }
            })
            return type
        },
        pushBatterySn(){
            let length = Object.keys(this.form.batteryListForm).length
            this.$set(this.form.batteryListForm,`item${length+1}`,{})
            this.$set(this.form.batteryListForm[`item${length+1}`],'sn','')
            this.$set(this.form.batteryListForm[`item${length+1}`],`date`,'')
            this.$set(this.form.batteryListForm[`item${length+1}`],`flag`,'1')
            this.$set(this.form.batteryListForm[`item${length+1}`],`index`,this.getRandomNumber(1000000,9999999))
        },
        returnFlag(data){
            // if(data.auditState == 0){
            //     if(data.type == 0 || data.type == 1){
            //         return false
            //     }else if(data.type == 2){
            //         return false
            //     }
            // }else if(data.auditState == 1){
            //     if(data.type == 2){
            //         return false
            //     }
            //     if(data.type == 0){
            //         return true
            //     }
            // }else{
            //     return false
            // }
            if(data.auditState == 0 && data.type == 0){
                return false
            }
            if(data.auditState == 0 && data.type == 1){
                return true
            }
            if(data.auditState == 0 && data.type == 2){
                return false
            }
            if(data.auditState == 1 && data.type == 2){
                return true
            }
            if(data.auditState == 1 && data.type == 0){
                return true
            }
        },
        returnExamineBattery(sn,id){
            if(!id){
                return false
            }
            if(this.unlockBattery){
                if(this.unlockBattery.indexOf(sn) != -1){
                    return true
                }else{
                    return false
                }
            }else{
                return false
            }
        },
        returnFlag2(data){
            if(data.auditState == 0){
                if(data.type == 1){
                    return true
                }else{
                return false
            }
            }else{
                return false
            }
        },
        async qualityGetById(sn){
            let res = await this.API.qualityGetById({
                inverterSn:sn
            })
            this.getBuyIdRes = res
            if(res){
                // res.auditState =1
                // res.type =2
                this.disabledFlag = this.returnFlag(res)
                this.disabledFlag2 = this.returnFlag2(res)
                Object.keys(this.form).forEach(item =>{
                    this.form[item] = res[item] || ''
                })
                this.$set(this.form,'IsSEACKIT',res.isSEACKIT == null ? '':res.isSEACKIT + '')
                this.unlockBattery = res.unlockBattery
                this.expireTime = res.expireTime
                if(res.nation == 'JAPAN'){
                    this.orderpaypalconfigGetInverterTypeList2()
                }
                this.form.batteryListForm = {item1:{sn:'',date:'',flag:'0'}}
                if(res.batteryList.length>0){
                    for(let i = 0;i<res.batteryList.length;i++){
                        this.$set(this.form.batteryListForm,`item${i+1}`,{})
                        this.$set(this.form.batteryListForm[`item${i+1}`],'sn',res.batteryList[i].batterySN)
                        this.$set(this.form.batteryListForm[`item${i+1}`],`date`,res.batteryList[i].installTime.split(' ')[0])
                        this.$set(this.form.batteryListForm[`item${i+1}`],`flag`,res.batteryList[i].enableFlag)
                        this.$set(this.form.batteryListForm[`item${i+1}`],`id`,res.batteryList[i].sid)
                        this.$set(this.form.batteryListForm[`item${i+1}`],`index`,i+1)
                    }
                }
                if(res.deviceType == 99){
                    this.form.model = this.$t('warranty.other')
                }
            }

        },
        blurBatterySn(sn){
            let reg = /^[A-Za-z0-9]+$/
            if(sn){
                var inverterSn = sn
                inverterSn = inverterSn.toUpperCase()
                sn = inverterSn
            }
            if(!reg.test(sn)){
                this.comm.showMsg(false, this.$t('warranty.batchSend.message5'))
                return false;
            }
            if(sn.split('').length != 14){
                this.comm.showMsg(false, this.$t('warranty.batchSend.message5'))
                return false;
            }
        },
        async qualitySave(){
            let reg = /^[A-Za-z0-9]+$/
            let reg2 = /^[A-Za-z0-9\-]+$/
            let checkFlag = this.returnSnFlag(this.form.model)
            if(this.form.inverterSn){
                var inverterSn = this.form.inverterSn
                inverterSn = inverterSn.toUpperCase()
                this.form.inverterSn = inverterSn
            }

            // if(!reg.test(this.form.inverterSn)){
            //     this.comm.showMsg(false, this.$t('warranty.batchSend.message4'))
            //     return false;
            // }
            if(checkFlag === 0){
                if(!reg2.test(this.form.inverterSn)){
                    this.comm.showMsg(false,this.$t('warranty.batchSend.message4'))
                    return false;
                }
            }else{
                if(!reg.test(this.form.inverterSn)){
                    this.comm.showMsg(false,this.$t('warranty.batchSend.message4'))
                    return false;
                }
            }
            if(this.form.inverterSn.split('').length != 14){
                this.comm.showMsg(false, this.$t('warranty.batchSend.message4'))
                return false;
            }
            if(this.form.batterySN){
                let res = await this.API.crmbatteryqualityCheckBatterySN({
                    batterySNList:this.form.batterySN
                })
                if(res.success == false){
                    if(res.object.length>0){
                        this.comm.showMsg(false,this.$t('warranty.newAddDataMsgRepeat')+res.object)
                    }else{
                        this.comm.showMsg(false,this.$t('index.control_fail'))
                    }
                    return
                }
            }
            let newObj = JSON.parse(JSON.stringify(this.form))
            if(this.returnOtherName(this.form.model) != 99){
                delete newObj.deviceTypeName
            }
            delete newObj.batteryList
            delete newObj.batteryListForm
            let res2 = await this.API.qualitySave(Object.assign({},newObj,{deviceType:this.deviceType}))
            if(res2.success){
                // this.$store.commit('setNewVisiblePvModules',false)
                // this.$emit('uploadData',true)
                this.comm.showMsg(res2.success,this.$t('warranty.successsMsg'))
            }else{
                if(res2.object=='1'){
                    // openMsg(getText("#msgErroy1"));
                    this.comm.showMsg(false,this.$t('warrantyManage.msgErroy1'))
					return
				}
				if(res2.object=='2'){
                    // openMsg(getText("#msgErroy2"));
                    this.comm.showMsg(false,this.$t('warrantyManage.msgErroy2'))
					return
				}
				if(res2.object=='3'){
                    // openMsg(getText("#msgErroy3"));
                    this.comm.showMsg(false,this.$t('warrantyManage.msgErroy3'))
					return
				}
				if(!res2.object){
                    // openMsg(res2.msg);
                    this.comm.showMsg(false,res2.msg)
					return
				}
            }
        },
        async qualitySendBatch(){
            let rows=this.selectDataList
            
            if(rows.length == 0){
                this.comm.showMsg(false,this.$t('device-chose-add-data'))
                return
            }
            for(var i=0;i<rows.length;i++){
                if(!rows[i].auditState){
                    this.comm.showMsg(false,this.$t('warranty.batchSend.message2'))
                    return
                }
            }
            let arr = []
            this.selectDataList.forEach(item=>{
                    arr.push(item.sid)
                })
            let res = await this.API.qualitySendInvoiceToUserBatch({
                ids:arr
            })
            if(this.comm.showMsg(res2.success)){
                this.query()
            }
        },
        async getInverterType(){
            let reg = /^[A-Za-z0-9\-]+$/
            if(this.form.inverterSn){
                var inverterSn = this.form.inverterSn
                inverterSn = inverterSn.toUpperCase()
                this.form.inverterSn = inverterSn
            }
            if(!reg.test(this.form.inverterSn)){
                this.comm.showMsg(false,this.$t('warranty.batchSend.message4'))
                return false;
            }
            if(this.form.inverterSn.split('').length != 14){
                this.comm.showMsg(false,this.$t('warranty.batchSend.message4'))
                return false;
            }

            if(!(this.form.inverterSn && this.form.inverterSn != this.oldSN)){
                return
            }
            let res = await this.API.orderpaypalconfigGetInverterType({
                inverterSn:this.form.inverterSn
            })
            if(res){
                this.form.model = res.inverterTypeName
                this.flagType = true
            }else{
                this.flagType = false
            }
            this.oldSN = this.form.inverterSn
        },
        async selectCountry(){
            let res = await this.API.selectCountry()
            this.nationList = res
        },
        nationChange(){
            if(this.form.nation == 'JAPAN'){
                this.orderpaypalconfigGetInverterTypeList2()
                this.form.model = ''
            }else{
                this.inverterType = this.copyInverter
            }
        },
        async orderpaypalconfigGetInverterTypeList2(){
            let res = await this.API.orderpaypalconfigGetInverterTypeList({
                inverterTypeName:this.form.nation
            })
            this.inverterType = res
        },
        async orderpaypalconfigGetInverterTypeList(){
            let res = await this.API.orderpaypalconfigGetInverterTypeList({
                lang:localStorage.getItem('lang')||'zh_CN'
            })
            this.inverterType = res
            this.copyInverter = res
        },
        returnSnFlag(code){
            let type = ''
            this.inverterType.forEach(item=>{
                if(item.inverterTypeName == code){
                    type = item.snCheckFlag
                }
            })
            return type
        },
        returnSoltSn(){
            let arr = []
            let lengths = Object.keys(this.form.batteryListForm)
            for(let i = 0;i<lengths.length;i++){
                if(i<this.form.batteryList.length){
                    if(this.form.batteryListForm[lengths[i]].sn !=this.form.batteryList[i].batterySN){
                        arr.push(this.form.batteryListForm[lengths[i]].sn)
                    }
                }else{
                     arr.push(this.form.batteryListForm[lengths[i]].sn)
                }
            }
            return arr.join(',')
        }, 
        async qualityUpdateForUser(){
            let resNew = await this.API.crmbatteryqualityCheckBatterySN({
                batterySNList:this.returnSoltSn()
            })
            if(resNew.success == false){
				if(resNew.object.length>0){
                    this.comm.showMsg(false,this.$t('warranty.newAddDataMsgRepeat')+resNew.object)
                    return
				}else{
                    this.comm.showMsg(false,this.$t('index.control_fail'))
                    return 
				}
			}
            let reg = /^[A-Za-z0-9]+$/
            let reg2 = /^[A-Za-z0-9\-]+$/
            let checkFlag = this.returnSnFlag(this.form.model)
            for(let key in this.form.batteryListForm){
                let sn = this.form.batteryListForm[key].sn
                if(sn){
                    if(sn){
                        var inverterSn = sn
                        inverterSn = inverterSn.toUpperCase()
                        sn = inverterSn
                    }
                    console.log(reg,'qualityUpdateForUser');
                    if(!reg.test(sn)){
                        this.comm.showMsg(false,this.$t('warranty.batchSend.message5'))
                        return false;
                    }
                    if(sn.split('').length != 14){
                        this.comm.showMsg(false,this.$t('warranty.batchSend.message5'))
                        return false;
                    }
                }
            }
            if(checkFlag === 0){
                if(!reg2.test(this.form.inverterSn)){
                    this.comm.showMsg(false,this.$t('warranty.batchSend.message4'))
                    return false;
                }
            }else{
                if(!reg.test(this.form.inverterSn)){
                    this.comm.showMsg(false,this.$t('warranty.batchSend.message4'))
                    return false;
                }
            }
            // if(!reg.test(this.form.inverterSn)){
            //     this.comm.showMsg(false,this.$t('warranty.batchSend.message4'))
            //     return false;
            // }
            if(this.form.inverterSn.split('').length != 14){
                this.comm.showMsg(false,this.$t('warranty.batchSend.message4'))
                return false;
            }
            let snArr = []
            for(let key in this.form.batteryListForm){
                if(this.form.batteryListForm[key].sn){
                    snArr.push(this.form.batteryListForm[key])
                }
            }
            let deleteBatteryIds = []
            snArr.forEach(item =>{
                if(item.id){
                    if(!item.sn){
                        deleteBatteryIds.push(item.id)
                    }
                }
            })
            let newObj = JSON.parse(JSON.stringify(this.form))
            delete newObj.batteryList
            delete newObj.batteryListForm
            if(this.disabledFlag){
                delete newObj.batterySN
                delete newObj.nation
                delete newObj.inverterSn
                delete newObj.delayCode
                delete newObj.saleCode
                delete newObj.installTime
            }
            let res = await this.API.qualityUpdateForUser(Object.assign({},newObj,{
                deviceType:this.deviceType,
                id:this.getBuyIdRes.sid,
                batterySNList:snArr.map(item=>{return item.sn}),
                batteryInstallTime:snArr.map(item=>{return item.date}),
                batteryEnableFlag:snArr.map(item=>{return item.flag}),
                batteryIdList:snArr.map(item=>{return item.id}),
                deleteBatteryIds:deleteBatteryIds.map(item=>{return item})
            }))
            if(res.success == false){
				if(res.object=='1'){
                    this.comm.showMsg(false,this.$t('warrantyManage.msgErroy1'))
					return
				}
				if(res.object=='2'){
                    this.comm.showMsg(false,this.$t('warrantyManage.msgErroy2'))
					return
				}
				if(res.object=='3'){
                    this.comm.showMsg(false, this.$t('warrantyManage.msgErroy3'))
					return
				}
				if(!res.object){
                    this.comm.showMsg(false, res.msg)
					return
				}
			}else{
                this.comm.showMsg(true, this.$t('index.control_success'))
			}
        },
        save(formName){
            this.$refs['form'].validate((valid) => {
              if (valid) {
                  if(!this.expireTime){
                      this.qualitySave()
                  }else{
                      this.qualityUpdateForUser()
                  }
              } else {
                console.log('error submit!!');
                return false;
              }
            });
        },
    },
};
</script>

<style  lang="less">
.warranty-mian-box-spa{
    height: 100%;
    .content-box{
        // position: relative;
        background: url('../../assets/img/warranty_bg.png') no-repeat;
        background-position: 100% 0%;
        height: calc(100% - 72px);
        width: calc(100% - 2px);
        border: 1px solid #fff;
            h1{
                text-align: center;
                margin-top: 100px;
                font-weight: 800;
                font-size: 60px;
            }
        .message-box-main{
            padding: 0px 50px;
            h3{
                font-size: 36px;
                font-weight: 700;
            }
            h6{
                margin-top: 20px;
                font-size: 18px;
                font-weight: 700;
            }
        }
        .form-item-bos{
            width: 100%;
        }
        .save-button-style{
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: #f6f6f6;
            text-align: center;
        }
        
    }
    .el-form--label-top .el-form-item__label{
            padding: 0 0 4px;
            font-weight: 500;
            font-size: 18px;
    }
    .el-select-dropdown{
        max-width: 243px;
    }
    .el-select-dropdown__item{
        display: inline-block;
    }
    .el-select-dropdown__item span {
        min-width: 205px;
        display: inline-block;
   }
}
</style>
